<template>
  <div class="mobile-container">
    <!-- 按钮列表容器 -->
    <div class="button-list">
      <!-- 动态渲染按钮 -->
      <el-button
          v-for="(btn, index) in buttons"
          :key="index"
          class="mobile-btn"
          @click="handleButtonClick(btn.classroomId)"
      >
        {{ btn.classroomName }}
      </el-button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import {useRouter} from "vue-router";
import {listClassroom} from "@/api/system/classroom.js";

const router = useRouter()

// 2. 按钮数据定义（预留后端接口位置）
const buttons = ref([])

const handleButtonClick = (id) => {
  let path = "/classroom?classroomId=" + id
  router.push(path)
}

function getList() {
  listClassroom().then(response => {
    buttons.value = response.rows;
  });
}
getList();
</script>

<style scoped>
/* 手机容器样式 */
.mobile-container {
  max-width: 100vw; /* 标准手机宽度 */
  height: 94vh; /* 标准手机高度 */
  background: #f5f5f5;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

/* 按钮列表布局 */
.button-list {
  display: flex;
  flex-direction: column;
  gap: 70px;
  padding: 20px; /* 替代容器的padding */
  margin-top: 8vh;
}

/* 移动端按钮样式 */
.mobile-btn {
  width: calc(100% - 40px); /* 抵消父容器padding */
  height: 70px;
  border-radius: 25px;
  font-size: 16px;
  background: linear-gradient(135deg, #409eff, #79bbff);
  color: white;
  border: none;
  transition: transform 0.2s;
  margin: 0 auto; /* 水平居中 */
  padding: 12px 0; /* 统一内边距 */
}

.mobile-btn:hover {
  transform: translateY(-2px);
}
</style>